package com.spukmk3me.impl.libgdx;

/* $if SPUKMK3ME_DEBUG$ */
import com.spukmk3me.debug.Logger;
/* $endif$ */
import com.spukmk3me.video.Image;
import com.spukmk3me.video.ImageRegion;

public class LibgdxImageRegion extends ImageRegion
{
    public LibgdxImageRegion( Image img, int x, int y, int w, int h )
    {
        super( img, x, y, w, h );
        
        u1 = (float)this.x / img.width();
        v1 = (float)(this.y + this.h ) / img.height();
        //v1 = (float)(img.height() - this.y - this.h + 1) / img.height();
        u2 = (float)(this.x + this.w ) / img.width();
        v2 = (float)this.y / img.height();
        //v2 = (float)(img.height() - this.y) / img.height();
        /* $if SPUKMK3ME_DEBUG $*/
        if ( img.getFileHandle() != null ) 
            Logger.log( "Created Libgdx image region: " + img.getFileHandle().getPath() + "|" + x + ", " + y + ", " + w + ", " + h + "\n" );
        /* $endif$ */
    }
    
    public LibgdxImageRegion duplicate()
    {
        return new LibgdxImageRegion( img, x, y, w, h );
    }
    
    final float u1, v1, u2, v2;
}
